<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
	</head>
	<body>
		<div id="app">
			<p>时间：{{ new Date() | formatDate }}</p>
		</div>
		
		
		<script>
			function add0(m) {
				return m < 10 ? '0' + m : m
			}
			let app = new Vue({
				el: "#app",
				data: {},
				filters: {
					formatDate: function(value) { // 格式化时间过滤器
						let y = value.getFullYear();
						let m = value.getMonth() + 1;
						let d = value.getDate();
						let h = value.getHours();
						let mm = value.getMinutes();
						let s = value.getSeconds();
						return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
					}
				}
			});
		</script>
	</body>
</html>
